package service.impl;

import bean.Member;
import dao.MemberDao;
import impl.MemberDaoImpl;
import service.MemberService;
import util.FileUtil;
import util.MD5Util;
import util.ServerResponseResult;

/**
 * @classname:MemberServiceImpl
 * @description:
 * @author: Mr.Z
 * @date: 2020/12/31 17:17
 * @version: 0.1
 * @since:1.8
 */
public class MemberServiceImpl implements MemberService {
    @Override
    public ServerResponseResult addMember(Member member) {
        String pass = member.getPass();
        String s = MD5Util.passMd5(pass);
        member.setPass(s);
        String image = member.getImage();
        String imagePath = FileUtil.fileUpload(image);
        member.setImage(imagePath);
        MemberDao memberDao = new MemberDaoImpl();
        int result = memberDao.addMember(member);
        if (result == 1) {
            return ServerResponseResult.success();
        }
        return ServerResponseResult.error();
    }


}
